import { defineComponent as V, ref as u, useAttrs as W, computed as I, watch as F, onMounted as O, openBlock as m, createElementBlock as v, createElementVNode as d, normalizeStyle as h, unref as p, mergeProps as T, Fragment as q, renderList as A, renderSlot as B } from "vue";
const E = /* @__PURE__ */ V({
  __name: "virtualList",
  props: {
    data: { default: [] },
    containerHeight: { default: "" },
    columns: { default: 0 }
  },
  setup(a) {
    const e = a;
    let o = u(0), r = u(0), c = u(0), g = u(0), i = u(0), y = u(0), w = u(null), S = W();
    const M = I(() => `translate3d(0,${c.value}px,0)`), k = I(() => e.data.slice(o.value, Math.min(r.value, e.data.length))), C = () => {
      let t = document.querySelector(".listContainer"), n = t == null ? void 0 : t.offsetHeight, l = e.columns > 0 ? e.columns : Math.ceil(n / i.value), s = Math.floor(t.scrollTop), f = Math.ceil(s / i.value);
      o.value = f, r.value = l + o.value, c.value = s - s % l;
    }, H = () => {
      var N, x;
      let t = document.querySelector(".listContainer"), n = w.value, l = t == null ? void 0 : t.offsetHeight, s = t == null ? void 0 : t.offsetWidth;
      i.value = n ? (N = n[0]) == null ? void 0 : N.offsetHeight : 1, y.value = n ? (x = n[0]) == null ? void 0 : x.offsetWidth : 1;
      let f = (s / y.value).toFixed(0), L = (e.data.length / f).toFixed(0);
      g.value = L * i.value, o.value = 0;
      let b = e.columns > 0 ? e.columns : Math.ceil(l / i.value);
      r.value = o.value + b;
    };
    return F(() => e.data, (t) => {
      H();
    }, { immediate: !0, deep: !0 }), O(() => {
      H();
    }), (t, n) => (m(), v("div", null, [
      d("div", {
        class: "listContainer",
        style: h({ height: p(e).containerHeight, width: "100%" }),
        onScroll: C
      }, [
        d("div", {
          class: "listContainerPhantom",
          style: h({ height: p(g) + "px" })
        }, null, 4),
        d("div", {
          class: "listContainerList",
          style: h({ transform: M.value })
        }, [
          d("div", T({ class: "list" }, p(S)), [
            (m(!0), v(q, null, A(k.value, (l, s) => (m(), v("div", {
              ref_for: !0,
              ref_key: "listItemRef",
              ref: w,
              key: s + "-" + (l == null ? void 0 : l.id)
            }, [
              B(t.$slots, "default", { data: l }, void 0, !0)
            ]))), 128))
          ], 16)
        ], 4)
      ], 36)
    ]));
  }
});
const P = (a, e) => {
  const o = a.__vccOpts || a;
  for (const [r, c] of e)
    o[r] = c;
  return o;
}, R = /* @__PURE__ */ P(E, [["__scopeId", "data-v-e9fe0bf2"]]), $ = [R], j = (a) => {
  $.map((e) => {
    a.component(e.__name, e);
  });
};
let _ = window;
if (typeof _ < "u" && _.Vue) {
  const a = _.Vue.createApp({});
  j(a);
}
export {
  j as default
};
